package com.xqboss.apps.dto.sys;

import com.xqboss.apps.dto.PageDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Objects;

/**
 * 用户信息表
 *
 * @author wangcong
 * @date 2023-08-28
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("用户信息Dto")
public class SysUserDto extends PageDto {

    @ApiModelProperty("用户昵称")
    @Length(min = 0, max = 10, message = "昵称不能超过10个字符")
    private String nickName;

    @ApiModelProperty("用户性别（0男 1女 2未知）")
    private String sex;

    @ApiModelProperty("头像地址")
    private String avatar;

    @ApiModelProperty("生日（yyyy-mm-dd）")
    private String birthday;

    @ApiModelProperty("身高（cm）")
    @Min(value = 0, message = "最小值为0")
    @Max(value = 300, message = "最大值为300")
    private Double height;

    @ApiModelProperty("体重（kg）")
    @Min(value = 0, message = "最小值为0")
    @Max(value = 200, message = "最大值为200")
    private Double weight;

    @ApiModelProperty("兴趣爱好 多个用,逗号隔开")
    private String hobbies;

    @ApiModelProperty("是否隐藏")
    private Boolean hidden;

    @ApiModelProperty("0正常，1停用")
    private String status;

    @ApiModelProperty("注册渠道 1安卓，2iOS")
    private Integer channel;

    @ApiModelProperty("搜索")
    private String search;

    @ApiModelProperty("00系统用户 01APP用户")
    private String userType;

    @ApiModelProperty("开始时间")
    private LocalDateTime createTimeStart;

    @ApiModelProperty("结束时间")
    private LocalDateTime createTimeEnd;

    public LocalDateTime getCreateTimeEnd() {
        if(Objects.nonNull(createTimeEnd)){
            return createTimeEnd.with(LocalTime.MAX);
        }
        return createTimeEnd;
    }
}
